#@head() 
#@header()
<title>辅助工具</title>
#@aside("marketing")
<div class="content-wrapper">
	<section class="content">
		<div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
             <li class="active"><a href="#(path)/admin/page/marketing-apphelp">银行编辑</a></li>
            </ul>
            <div class="tab-content">
              <div class="tab-pane active" id="tab_1">
				<div class="box-body">
					<table id="example1" style="width:50%;" class="table table-striped"> 
						<tbody>
							<tr>
								<th align="right" style="">银行名称：</th>
								<td><input id="name" type="text" style="width:300px;float:left" class="form-control" placeholder="银行名称"></td>
							</tr>
							
							<tr>
								<th align="right" style="width:100px;">银行编号：</th>
								<td><input id="code" type="text" style="width:300px;float:left" class="form-control" placeholder="银行编号"></td>
							</tr>
							<tr>
								<th align="right" style="width:100px;">单笔限额：</th>
								<td><input id="single" type="text" style="width:300px;float:left" class="form-control" placeholder="单笔限额"><div style="float:left;line-height:30px;">&nbsp;(元)</div></td>
							</tr>
							<tr>
								<th align="right" style="width:100px;">每日限额：</th>
								<td><input id="day" type="text" style="width:300px;float:left" class="form-control" placeholder="每日限额"><div style="float:left;line-height:30px;">&nbsp;(元)</div></td>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="box-footer">
					<button id="submit_bank" type="submit" style="margin-left:50px;" class="btn btn-info ">提交</button>
				  </div>
              </div>
            </div> 
            <!-- /.tab-content -->
          </div> 
	</section>
</div>
#@footer()

<script>
var id = GetRequest().id;
if(!$.isBlank(id)){
	$.getJSON("/bank/info?token=#(session.token??)&id="+id, function(userli) {
		var item = userli.data.item;
		$("#name").val(item.name);
		$("#code").val(item.code);
		$("#single").val(item.single);
		$("#day").val(item.day);
	});	
}else{
	id="";
}
$("#submit_bank").click(function(){
	var name = $("#name").val();
	var code = $("#code").val();
	var single = $("#single").val();
	var day = $("#day").val();
	if($.isBlank(name)){
		layer.msg("银行名称未填写！",{icon:2,time:1000});
	}else if($.isBlank(code)){
		layer.msg("银行编号未填写！",{icon:2,time:1000});
	}else if($.isBlank(single)){
		layer.msg("单笔限额未填写！",{icon:2,time:1000});
	}else if($.isBlank(day)){
		layer.msg("每日限额未填写！",{icon:2,time:1000});
	}else{
		$.getJSON("/bank/edit?token=#(session.token??)&id="+id+"&name="+name+"&code="+code+"&single="+single+"&day="+day, function(datainfo) {
			if(datainfo.code=='success'){
				layer.msg(datainfo.msg,{icon:1,time:1000},function(){
					window.location.href="#(path)/admin/page/marketing-banklist"; 
				}); 
			}else{
				layer.msg(datainfo.msg,{icon:2,time:1000}); 
			}
		});	
	}
});
function GetRequest() {  
	   var url = location.search; //获取url中"?"符后的字串  
	   var theRequest = new Object();  
	   if (url.indexOf("?") != -1) {  
		  var str = url.substr(1);  
		  strs = str.split("&");  
		  for(var i = 0; i < strs.length; i ++) {  
			 theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);  
		  }  
	   }  
	   return theRequest;  
	}  
</script>
</body>
</html>

